import Vue from "vue";
import Router from "vue-router";

import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import i18n from "./lang";

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";

import "@/styles/index.scss"; // global css

import App from "./Dashboard.vue";
import store from "./store";

import { Loading, MessageBox, Message, Notification } from "element-ui";

import echarts from 'echarts'

import dataV from '@jiaminghi/data-view'

import Viser from 'viser-vue'

Vue.use(Viser);

Vue.use(dataV);
Vue.prototype.$echarts = echarts

Vue.prototype.$loading = Loading.service;
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$prompt = MessageBox.prompt;
Vue.prototype.$notify = Notification;
Vue.prototype.$message = Message;

Vue.use(ElementUI);


Vue.config.productionTip = false;

const router = new Router({
  mode: "hash",
  routes: [
    {
      path: "/index",
      name: "index",
      component: () => import("@/dashboard/views/index"),
      meta: {
        title: "大屏"
      }
    }
  ]
});

router.afterEach(to => {
  const nearestWithTitle = to.matched
    .slice()
    .reverse()
    .find(r => r.meta && r.meta.title);
  let title = "";
  if (nearestWithTitle) title = nearestWithTitle.meta.title;

  document.title = title;
});

new Vue({
  el: "#app",
  router,
  i18n,
  render: h => h(App)
});
